﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace WebManager.Function.PortalList
{
    public partial class Edit : System.Web.UI.Page
    {
        int EditID;
        protected void Page_Load(object sender, EventArgs e)
        {
           
            if (HttpContext.Current.Request.QueryString["EditID"] == null
               || (HttpContext.Current.Request.QueryString["EditID"] == ""))
            {
                return;
            }           
            
            EditID = Convert.ToInt32(HttpContext.Current.Request.QueryString["EditID"]);  
            
            if (!Page.IsPostBack)
            {               
                Label label = Page.Master.FindControl("lblTitle") as Label;
                label.Text = "<b>添加PortalList</b>";
                LYQ.BLL.PortalList bll = new LYQ.BLL.PortalList();
                LYQ.Model.PortalList model = bll.GetModel(EditID);
                txtPortalName.Text = model.PortalName;
                txtLimit.Text = model.Limit.ToString();
                txtDescription.Text = model.Description;
            }

        }

        protected void Save_Click(object sender, EventArgs e)
        {
            LYQ.BLL.PortalList bll = new LYQ.BLL.PortalList();
            LYQ.Model.PortalList model = new LYQ.Model.PortalList();
            model.PortalID = EditID;
            model.PortalName = txtPortalName.Text;
            model.Limit = Convert.ToInt32(txtLimit.Text);
            model.Description = txtDescription.Text;

            bll.Update(model);

            string url = URLUtility.UrlBase + "/WebManager/Function/PortalList/List.aspx";
            Page.Response.Redirect(url);
        }

        protected void Cancel_Click(object sender, EventArgs e)
        {
            string url = URLUtility.UrlBase + "/WebManager/Function/PortalList/List.aspx";
            Page.Response.Redirect(url);
        }
    }
}
